package com.nightsoul.jamon.test;

import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.webapp.WebAppContext;

public class Launcher {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		Server server = new Server(8080);
		
		String userDir = System.getProperty("user.dir");
		String webApp = userDir + "/src/main/webapp";
		WebAppContext jamonTest = new WebAppContext(webApp, "/jamontest");
		WebAppContext jamonAdmin = new WebAppContext(Launcher.class.getResource("/jamon.war").getFile(), "/jamonadmin");
		
		HandlerCollection handlerCollection = new HandlerCollection();
		Handler[] handlers = new Handler[] {jamonTest, jamonAdmin};
		handlerCollection.setHandlers(handlers);
		
		jamonTest.setDefaultsDescriptor(Launcher.class.getResource("/webdefault.xml").getFile());
		server.setHandler(handlerCollection);
		
		
		server.start();
		server.join();
	}

}
